/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TP3;

/**
 *
 * @author augusto
 */
public class GeneradorDeDistribuciones {
    
    
  public double generarUniforme(double random,double a,double b)
   {   double resultado=0;
        resultado=random*(b-a)+a;
        return resultado;
    }
    
    
  public double[] generarExponencialNegativa(int muestra,double media)
   {    double vector[]=new double[muestra];
       for (int i = 0; i < muestra; i++) {
        vector[i]= (-media)*(Math.log(1-Math.random()));  
       }
        
   
    return vector;
   }  

  public  double generarNormal(float media, float desviacion) {
        double suma=0;
        for (int i = 0; i < 12; i++) {
            suma=suma+Math.random();
        }
        suma=(suma-6)*desviacion+media;
        return suma;
    }
  
  public double generarPoisson(double lamda)
  { double resul=0;
     double p=1;
     double x=-1;
     double a= Math.pow( Math.E, -lamda);  
     do{
     double rand=Math.random();
         p=p*rand;
         x=x+1;
     }while(p>=a);
    resul=x; 
     
  return resul;
  }
    
}
